//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//
// (C) Copyright 2006 Marvell International Ltd.
// All Rights Reserved
//

#include <windows.h>
#include <ceddk.h>
#include <oal.h>
#include "oal_kitl.h"



//------------------------------------------------------------------------------
//
//  Function:  OALKitlStart
//
//  This function is called from OEMInit to start KITL. It usualy set KITL
//  configuration and it calls OALKitlInit
//

BOOL OALKitlStart()
{
    return TRUE;
}

//------------------------------------------------------------------------------
//
//  Function:  OALKitlInitRegistry
//
//  This function is called as part of IOCTL_HAL_INITREGISTRY to update
//  registry with information about KITL device. This must be done to avoid
//  loading Windows CE driver in case that it is part of image. On system
//  without KITL is this function replaced with empty stub.
//

static void UpdateKITLReg(DWORD cfg)
{
    DWORD status;
    HKEY Key;
    DWORD dwDisp;
    status = NKRegCreateKeyEx(HKEY_LOCAL_MACHINE, OAL_KITL_REG_KEY_NAME, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &Key, &dwDisp);
    if (status != ERROR_SUCCESS)
    {
        OALMSG(OAL_KITL&&OAL_FUNC, (TEXT("Cannot update OAL KITL Reg information.\r\n")));
        return;
    }
    status = NKRegSetValueEx(Key, OAL_KITL_REG_VALUE_NAME_CFG, 0, REG_DWORD, (BYTE *)&cfg, sizeof(cfg));
    if (status != ERROR_SUCCESS)
    {
        OALMSG(OAL_KITL&&OAL_FUNC, (TEXT("Cannot update OAL KITL Reg information.\r\n")));
    }
    NKRegCloseKey(Key);
}

VOID OALKitlInitRegistry()
{
    OALMSG(OAL_KITL&&OAL_FUNC, (L"+ALKitlInitRegistry -- NONE KITL version default to none\r\n"));
    UpdateKITLReg(OAL_KITL_REG_TYPE_NONE);
    OALMSG(OAL_KITL&&OAL_FUNC, (L"-OALKitlInitRegistry\r\n"));
}

//------------------------------------------------------------------------------
//
//  Function:  OALKitlPowerOff
//
//  This function is called as part of OEMPowerOff implementation. It should
//  save all information about KITL device and put it to power off mode.
//
VOID OALKitlPowerOff()
{
}

//------------------------------------------------------------------------------
//
//  Function:  OALKitlPowerOn
//
//  This function is called as part of OEMPowerOff implementation. It should
//  restore KITL device back to working state.
//
VOID OALKitlPowerOn()
{
}

//------------------------------------------------------------------------------
//
//  Function:  OALIoCtlVBridge
//
//  This function implement OEMIoControl calls for VMINI related IOCTL codes.
//
BOOL OALIoCtlVBridge(
    UINT32 code, VOID *pInpBuffer, UINT32 inpSize, VOID *pOutBuffer,
    UINT32 outSize, UINT32 *pOutSize
) {
    return FALSE;
}

//------------------------------------------------------------------------------
